<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
		<script type="text/javascript">
			var bg = chrome.extension.getBackgroundPage();
			var installDone = localStorage["installDone"];
			var username = localStorage["username"];
			var password = localStorage["password"];
			var devicename = localStorage["devicename"];
			var replace_chrome_history = localStorage["replace_chrome_history"];
			var import_chrome_history = localStorage["import_chrome_history"];
			var sync_local_to_server = localStorage["sync_local_to_server"];
			var sync_server_to_local = localStorage["sync_server_to_local"];
			var wanted_devices = localStorage["wanted_devices"];
			var server_url = localStorage["server_url"];
			var lastDevicesSyncTimes= localStorage["lastDevicesSyncTimes"];
			var lastLocal2ServSync= localStorage["lastLocal2ServSync"];
			
			function showChoice(fadeout,fadein) {
				console.log("showChoice");
				$('#content').fadeOut(fadeout, function() {
					$("#content").fadeIn(fadein).load('optionpages/choice.html');
  				});
				//$('#content').toggle();
				
			}
			function showNewuser(fadeout,fadein) {
				console.log("showNewuser");
				$('#content').fadeOut(fadeout, function() {
					$("#content").fadeIn(fadein).load('optionpages/newuser.html');
  				});
			}
			function showExistinguser(fadeout,fadein) {
				console.log("showExistinguser");
				$('#content').fadeOut(fadeout, function() {
					$("#content").fadeIn(fadein).load('optionpages/existinguser.html');
  				});				
			}
			function showFinishsetup(fadeout,fadein) {
				console.log("showFinishsetup");
				$('#content').fadeOut(fadeout, function() {
					$("#content").fadeIn(fadein).load('optionpages/finishsetup.html');
  				});				
			}
			function showNormaloptions(fadeout,fadein) {
				console.log("showNormaloptions");
				$('#content').fadeOut(fadeout, function() {
					$("#content").fadeIn(fadein).load('optionpages/normaloptions.html');
  				});
			}
			function showFinishlogin(fadeout,fadein) {
				console.log("showFinishlogin");
				$('#content').fadeOut(fadeout, function() {
					$("#content").fadeIn(fadein).load('optionpages/finishlogin.html');
  				});
			}			
			
			// Saves options to localStorage.
			function save_options() {
				
			}

			

			function init() {
				 //restore_options();
				 
				 if(installDone==='true'){
				 	
				 	showNormaloptions(0,300);
				 }else{
				 	//reset vars
				 	username = localStorage["username"];
					password = localStorage["password"];
					devicename = localStorage["devicename"];
					replace_chrome_history = localStorage["replace_chrome_history"];
					sync_local_to_server = localStorage["sync_local_to_server"];
					sync_server_to_local = localStorage["sync_server_to_local"];
					wanted_devices = localStorage["wanted_devices"];
				 	
				 	//default server
				 	server_url="http://localhost/chs/interaction.php"
				 	showChoice(0,300);
				 }
				 
			}
			

			function registerClicks() {
				$('#button1').click(function() {					
					init();
				});
			};

			$(function() {
				init();
				registerClicks();				
			});
			
			
		</script>
		<title id="title"></title>
	</head>
	<body>
		<div id="header">
		<button type="button" id="button1">Reset Setup</button>
		</div>
		<br/>
		<div id="info"></div>
		<div id="content"></div>
	</body>
</html>
